var style = [];  // creates new and nested arrays
for (var i = 1; i <= 28; i++) {
    style[i] = [];
	for (var j = 0; j<=6; j++) {
		
		style[i][j] = [];
	}
}

style[1][0] = "LIGHT LAGER";
style[1][1] = "1A. Lite American Lager";
style[1][2] = "1B. Standard American Lager";
style[1][3] = "1C. Premium American Lager";
style[1][4] = "1D. Munich Helles";
style[1][5] = "1E. Dortmunder Export";

style[2][0] = "PILSNER";
style[2][1] = "2A. German Pilsner (Pils)";
style[2][2] = "2B. Bohemian Pilsner";
style[2][3] = "2C. Classic American Pilsner";

style[3][0] = "EUROPEAN AMBER LAGER";
style[3][1] = "3A. Vienna Lager";
style[3][2] = "3B. Oktoberfest/Märzen";

style[4][0] = "DARK LAGER";
style[4][1] = "4A. Dark American Lager";
style[4][2] = "4B. Munich Dunkel";
style[4][3] = "4C. Schwarzbier";

style[5][0] = "BOCK";
style[5][1] = "5A. Maibock/Helles Bock";
style[5][2] = "5B. Traditional Bock";
style[5][3] = "5C. Doppelbock";
style[5][4] = "5D. Eisbock";

style[6][0] = "LIGHT HYBRID BEER";
style[6][1] = "6A. Cream Ale";
style[6][2] = "6B. Blonde Ale";
style[6][3] = "6C. Kölsch";
style[6][4] = "6D. American Wheat or Rye Beer";

style[7][0] = "AMBER HYBRID BEER";
style[7][1] = "7A. North German Altbier";
style[7][2] = "7B. California Common Beer";
style[7][3] = "7C. Düsseldorf Altbier";

style[8][0] = "ENGLISH PALE ALE";
style[8][1] = "8A. Standard/Ordinary Bitter";
style[8][2] = "8B. Special/Best/Premium Bitter";
style[8][3] = "8C. Extra Special/Strong Bitter (English Pale Ale)";

style[9][0] = "SCOTTISH AND IRISH ALE";
style[9][1] = "9A. Scottish Light 60/-";
style[9][2] = "9B. Scottish Heavy 70/-";
style[9][3] = "9C. Scottish Export 80/-";
style[9][4] = "9D. Irish Red Ale";
style[9][5] = "9E. Strong Scotch Ale";

style[10][0] = "AMERICAN ALE";
style[10][1] = "10A. American Pale Ale";
style[10][2] = "10B. American Amber Ale";
style[10][3] = "10C. American Brown Ale";

style[11][0] = "ENGLISH BROWN ALE";
style[11][1] = "11A. Mild";
style[11][2] = "11B. Southern English Brown Ale";
style[11][3] = "11C. Northern English Brown Ale";

style[12][0] = "PORTER";
style[12][1] = "12A. Brown Porter";
style[12][2] = "12B. Robust Porter";
style[12][3] = "12C. Baltic Porter";

style[13][0] = "STOUT";
style[13][1] = "13A. Dry Stout";
style[13][2] = "13B. Sweet Stout";
style[13][3] = "13C. Oatmeal Stout";
style[13][4] = "13D. Foreign Extra Stout";
style[13][5] = "13E. American Stout";
style[13][6] = "13F. Imperial Stout";

style[14][0] = "INDIA PALE ALE (IPA)";
style[14][1] = "14A. English IPA";
style[14][2] = "14B. American IPA";
style[14][3] = "14C. Imperial IPA";

style[15][0] = "GERMAN WHEAT AND RYE BEER";
style[15][1] = "15A. Weizen/Weissbier";
style[15][2] = "15B. Dunkelweizen";
style[15][3] = "15C. Weizenbock";
style[15][4] = "15D. Roggenbier (German Rye Beer)";

style[16][0] = "BELGIAN AND FRENCH ALE";
style[16][1] = "16A. Witbier";
style[16][2] = "16B. Belgian Pale Ale";
style[16][3] = "16C. Saison";
style[16][4] = "16D. Bière de Garde";
style[16][5] = "16E. Belgian Specialty Ale";

style[17][0] = "SOUR ALE";
style[17][1] = "17A. Berliner Weisse";
style[17][2] = "17B. Flanders Red Ale";
style[17][3] = "17C. Flanders Brown Ale/Oud Bruin";
style[17][4] = "17D. Straight (Unblended) Lambic";
style[17][5] = "17E. Gueuze";
style[17][6] = "17F. Fruit Lambic";

style[18][0] = "BELGIAN STRONG ALE";
style[18][1] = "18A. Belgian Blond Ale";
style[18][2] = "18B. Belgian Dubbel";
style[18][3] = "18C. Belgian Tripel";
style[18][4] = "18D. Belgian Golden Strong Ale";
style[18][5] = "18E. Belgian Dark Strong Ale";

style[19][0] = "STRONG ALE";
style[19][1] = "19A. Old Ale";
style[19][2] = "19B. English Barleywine";
style[19][3] = "19C. American Barleywine";

style[20][0] = "FRUIT BEER";
style[20][1] = "20. Fruit Beer";

style[21][0] = "SPICE/HERB/VEGETABLE BEER";
style[21][1] = "21A. Spice, Herb, or Vegetable Beer";
style[21][2] = "21B. Christmas/Winter Specialty Spiced Beer";

style[22][0] = "SMOKE-FLAVORED & WOOD-AGED BEER";
style[22][1] = "22A. Classic Rauchbier";
style[22][2] = "22B. Other Smoked Beer";
style[22][3] = "22C. Wood-Aged Beer";

style[23][0] = "SPECIALTY BEER";
style[23][1] = "23. Specialty Beer";

style[24][0] = "TRADITIONAL MEAD";
style[24][1] = "24A. Dry Mead";
style[24][2] = "24B. Semi-Sweet Mead";
style[24][3] = "24C. Sweet Mead";

style[25][0] = "MELOMEL (FRUIT MEAD)";
style[25][1] = "25A. Cyser (Apple Melomel)";
style[25][2] = "25B. Pyment (Grape Melomel)";
style[25][3] = "25C. Other Fruit Melomel";

style[26][0] = "OTHER MEAD";
style[26][1] = "26A. Metheglin";
style[26][2] = "26B. Braggot";
style[26][3] = "26C. Open Category Mead";

style[27][0] = "STANDARD CIDER AND PERRY";
style[27][1] = "27A. Common Cider";
style[27][2] = "27B. English Cider";
style[27][3] = "27C. French Cider";
style[27][4] = "27D. Common Perry";
style[27][5] = "27E. Traditional Perry";

style[28][0] = "SPECIALTY CIDER AND PERRY";
style[28][1] = "28A. New England Cider";
style[28][2] = "28B. Fruit Cider";
style[28][3] = "28C. Apple Wine";
style[28][4] = "28D. Other Specialty Cider or Perry";    



var alphabet = "ABCDEFGHIJ";

function selectField(idValue, nameValue, targetDiv, optionValue) {
	// optionValue (stylenumber, nameonly, fullname)
	var opt1 = '<option value="';
	var opt2 = '">';
	var opt3 = '</option>';
	var selectFieldHTML = '<select id="'+idValue+'" name="'+nameValue+'">';
	for (i=1; i<style.length; i++) {
		for (j=0; j<style[i].length; j++) {
			if (j == 0) selectFieldHTML = selectFieldHTML + '<optgroup label="' +i+ '. ' +style[i][j]+'">';
			if ((j > 0)&&(style[i][j] != "")) {
				var optiontag;
				var valueOutput; 
				switch(optionValue) {
					case "stylenumber":
						valueOutput = i;
						if ((i !=  23) && (i != 20)) valueOutput = valueOutput + alphabet[j-1];  // catch exceptions with only one style (#20 and #23)
					break;
					case "nameonly":
						var name = style[i][j].split(". ");
						valueOutput = name[1];
					break;
					default:
						valueOutput = style[i][j]; 
					break;
				}
				selectFieldHTML = selectFieldHTML + opt1 + valueOutput + opt2 + style[i][j] + opt3;	
			}
		}
		selectFieldHTML = selectFieldHTML + '</optgroup>';
	}
	selectFieldHTML = selectFieldHTML + '</select>';	
	$('#'+targetDiv).append(selectFieldHTML);
}

function nestedList(targetDiv, idValue) {
	var nestedList = "<ol id='"+idValue+"'>";
		
	for (i=1; i<style.length; i++) {
		for (j=0; j<style[i].length; j++) {
			if (j == 0) nestedList = nestedList + '<li>' +style[i][j]+'<ul>';
			if ((j > 0)&&(style[i][j] != "")) {
				
				nestedList = nestedList + '<li>' + style[i][j] + '</li>';	
			}
		}
		nestedList = nestedList + '</ul></li>';
	}
		
	nestedList = nestedList + "</ol>";	
	$('#'+targetDiv).append(nestedList);
}

function nestedToggleList(targetDiv, idValue, toggleSpeed) {
	var nestedList = "<ol id='"+idValue+"'>";
		
	for (i=1; i<style.length; i++) {
		for (j=0; j<style[i].length; j++) {
			if (j == 0) nestedList = nestedList + '<li><a href="#">' +style[i][j]+'</a><ul>';
			if ((j > 0)&&(style[i][j] != "")) {
				
				nestedList = nestedList + '<li><a href="#">' + style[i][j] + '</a></li>';	
			}
		}
		nestedList = nestedList + '</ul></li>';
	}
		
	nestedList = nestedList + "</ol>";	
	$('#'+targetDiv).append(nestedList);
	
	$('#'+idValue).children('li').children('ul').toggle();
	$('#'+idValue).children('li').children('a').click(function(event) {
        $(this).next('ul').toggle(toggleSpeed);
		event.preventDefault();
    });
	
}